<template>
  <div class="page-content-base">
    <div class="page-content-title">
     <div class="page-content-title-search">
       <a-space>
          <a-button type="primary" @click="ClickBack">返回管理界面</a-button>
       </a-space>
      </div>
      <h3 class="page-content-title-name">任务分配：类型>{{manager_type_name}}               任务号>{{mergeid}}</h3>
    </div>
    <div class="page-content-forms">
      <div style="margin-left: 10px;">
        <label>实施小组：</label>
        <a-select style="width: 240px" @change="orgSelectChange" allowClear v-model="org" option-label-prop="label">
          <a-select-option :value="item.id" :label="item.name" v-for="(item,index) in $store.state.orgs" :key="index">{{item.name}}</a-select-option>
        </a-select>
      </div>
      <div style="margin-left: 10px;">
        <label>实施角色：</label>
        <a-select style="width: 240px" @change="roleSelectChange" allowClear v-model="role" option-label-prop="label">
          <a-select-option :value="item.id" :label="item.name" v-for="(item,index) in $store.state.roles" :key="index">{{item.name}}</a-select-option>
        </a-select>
      </div>
      <div style="margin-left: 10px;">
        <label>实施人员：</label>
        <a-select style="width: 160px" @change="NameSelectChange" allowClear v-model="qs_form.name">
          <a-select-option :value="item.fullname" v-for="(item,index) in getActiveUsers" :key="index">{{item.fullname}}</a-select-option>
        </a-select>
      </div>
       <div style="margin-left: 10px;">
        <label>选定流程：</label>
        <a-select style="width: 120px" @change="workSelectChange"  v-model="work_type">
          <a-select-option :value="item.type" v-for="(item,index) in $store.state.bigdata_sample_works" :key="index">{{item.name}}</a-select-option>
        </a-select>
      </div>
      <div style="margin-left: 10px;">
        <label>图斑状态：</label>
        <a-select style="width: 320px" @change="StatusSelectChange" allowClear v-model="qs_form.status" v-show="work_type=='change'">
          <a-select-option :value="item.status" v-for="(item,index) in $store.state.detail_status" :key="index" :disabled="item.disabled">{{item.name}}</a-select-option>
        </a-select>
        <a-select style="width: 320px" @change="StatusSelectChange" allowClear v-model="qs_form.status" v-show="work_type=='changecheck'||work_type=='editcheck'">
          <a-select-option :value="-2" >未实施</a-select-option>
          <a-select-option :value="1" >正确</a-select-option>
          <a-select-option :value="2" >错误</a-select-option>
        </a-select>
        <a-select style="width: 320px" @change="StatusSelectChange" allowClear v-model="qs_form.status" v-show="work_type=='edit'">
          <a-select-option :value="-2" >未实施</a-select-option>
          <a-select-option :value="1" >未编辑</a-select-option>
          <a-select-option :value="2" >已编辑</a-select-option>
        </a-select>
      </div>
      <div class="page-content-title-search" style="position: absolute;right: 100px;">
       <a-space>
          <a-button type="primary" @click="ClickSearch">查询</a-button>
          <a-button type="primary" @click="ClickFenPeiGouXuan" v-show="can_fenpei">勾选分配</a-button>
          <a-button type="primary" @click="ClickFenPeiIn" v-show="can_fenpei">输入分配</a-button>
       </a-space>
      </div>
    </div>
    <div class="page-content-table" style="margin-top: 10px;">
      <a-table :columns="columns" :data-source="task_one_table_data" bordered :pagination="task_one_pagination"  size="small"
      @change="changeEvent"
      :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onTableSelectChange }"
      >
        <p slot="expandedRowRender" slot-scope="record" style="margin: 0">
          <a-descriptions bordered="true" size="small" :column="4"> 
            <a-descriptions-item label="前时相">{{record.properties.other.QSX}}</a-descriptions-item>
            <a-descriptions-item label="前影像" >{{record.properties.other.QQJH}}</a-descriptions-item>
            <a-descriptions-item label="后时相">{{record.properties.other.HSX}}</a-descriptions-item>
            <a-descriptions-item label="后影像" >{{record.properties.other.DQJH}}</a-descriptions-item>

            <a-descriptions-item label="行政区划代码">{{record.properties.other.XZQDM}}</a-descriptions-item>
            <a-descriptions-item label="行政区划名称">{{record.properties.other.XMC}}</a-descriptions-item>
            <a-descriptions-item label="变化图斑编号" :span="2">{{record.properties.other.JVBH}}</a-descriptions-item>


            <a-descriptions-item label="变化判别">NUll</a-descriptions-item>
            <a-descriptions-item label="判别人员">{{record.properties[manager_task_type].change.name}}</a-descriptions-item>
            <a-descriptions-item label="判别状态" >{{GettFenPeiStatusFor(record,"change")}}</a-descriptions-item>
            <a-descriptions-item label="判别时间" >{{GetTime(record.properties[manager_task_type].change.time)}}</a-descriptions-item>

            <a-descriptions-item label="变化判别检查">NUll</a-descriptions-item>
            <a-descriptions-item label="判别检查人员">{{record.properties[manager_task_type].changecheck.name}}</a-descriptions-item>
            <a-descriptions-item label="判别检查状态" >{{record.properties[manager_task_type].changecheck.status==-2?"未实施":record.properties[manager_task_type].changecheck.status==1?"正确":"错误"}}</a-descriptions-item>
            <a-descriptions-item label="判别检查时间" >{{GetTime(record.properties[manager_task_type].changecheck.time)}}</a-descriptions-item>


            <a-descriptions-item label="图形编辑">NUll</a-descriptions-item>
            <a-descriptions-item label="图形编辑人员">{{record.properties[manager_task_type].edit.name}}</a-descriptions-item>
            <a-descriptions-item label="图形编辑状态" >{{record.properties[manager_task_type].changecheck.status==-2?"未实施":record.properties[manager_task_type].changecheck.status==1?"未编辑":"已编辑"}}</a-descriptions-item>
            <a-descriptions-item label="图形编辑时间" >{{GetTime(record.properties[manager_task_type].edit.time)}}</a-descriptions-item>


            <a-descriptions-item label="图形编辑检查">NUll</a-descriptions-item>
            <a-descriptions-item label="图形编辑人员">{{record.properties[manager_task_type].editcheck.name}}</a-descriptions-item>
            <a-descriptions-item label="图形编辑状态" >{{record.properties[manager_task_type].changecheck.status==-2?"未实施":record.properties[manager_task_type].changecheck.status==1?"正确":"错误"}}</a-descriptions-item>
            <a-descriptions-item label="图形编辑时间" >{{GetTime(record.properties[manager_task_type].editcheck.time)}}</a-descriptions-item>
          </a-descriptions>
        </p>
        <span slot="taskid" slot-scope="text, record"> 
          <span class="menu-name"  style="user-select: text;">{{record.properties.taskid}}</span>
        </span>
        <span slot="code" slot-scope="text, record"> 
          <span class="menu-name"  style="user-select: text;">{{record.properties.other.JVBH}}</span>
        </span>
        <span slot="name" slot-scope="text, record">
          <span class="menu-name" >{{record.properties[manager_task_type][work_type].name}}</span>
        </span>
        <span slot="preimage" slot-scope="text, record"> 
          <div class="showimg" style="width: 30px;height: 30px;position: relative;">
              <img :src="Get_img(record.properties.preimage)" style="width: 100%;height: 100%;"/>
              <div class="demo-upload-list-cover" style="width: 100%;height: 100%;">
                <a-icon type="eye"  title="预览" @click.native="handleView(Get_img(record.properties.preimage),mergeid,record.properties.taskid,record.properties.other.JVBH)"/>
              </div>
          </div>
        </span>
        <span slot="lstimage" slot-scope="text, record"> 
          <div class="showimg" style="width: 30px;height: 30px;position: relative;">
              <img :src="Get_img(record.properties.lstimage)" style="width: 100%;height: 100%;"/>
              <div class="demo-upload-list-cover" style="width: 100%;height: 100%;">
                <a-icon type="eye"  title="预览" @click.native="handleView(Get_img(record.properties.lstimage),mergeid,record.properties.taskid,record.properties.other.JVBH)"/>
              </div>
          </div>
        </span>
        <span slot="time" slot-scope="text, record"> 
          <span class="menu-name">{{GetTime(record.properties[manager_task_type][work_type].time)}}</span>
        </span>
        <span slot="status" slot-scope="text, record"> 
          <a-badge v-show="work_type=='change'" :color="GetFenPeiStatusColor(record.properties[manager_task_type][work_type].status)" :text="GettFenPeiStatusFor(record,'change')" />
          <a-badge v-show="work_type=='changecheck'" :color="GetPYstatus(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'正确':'错误'" />
          <a-badge v-show="work_type=='edit'" :color="GetEDITstatus(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'未编辑':'已编辑'" />
          <a-badge v-show="work_type=='editcheck'" :color="GetPYstatus(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'正确':'错误'" />
          <!-- <a-badge v-show="work_type=='prop'" :color="GetEDITstatus(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'未编辑':'已编辑'" />
          <a-badge v-show="work_type=='propcheck'" :color="GetPYstatus(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'正确':'错误'" /> -->
        </span>
        <span slot="operation" slot-scope="text, record">
          <!-- :disabled="!(record.properties[manager_task_type][work_type].status==7)" -->
          <a-button class="operation-a" type="link"  @click="FenPeiAdmin(record['_id'])"  v-show="can_fenpei">分配</a-button>
          <a-button class="operation-a" type="link"  @click="ShowModel(record)">预览</a-button>
        </span>
      </a-table>
    </div>
    
    
    
  </div>
</template>
<script>
// document.onkeydown = (e)=> {}
export default {
  data() {
    return {
      mergeid:'', //外部传入
      can_fenpei:false,//外部传入
      manager_type_name:"执法服务",//外部传入
      manager_task_type:"bigdata",//外部传入

      
      //外部传入
      columns:[
        {
            title: 'AI编号',
            scopedSlots: { customRender: 'taskid' },
            key: 'code',
            width:310,
            align:'center'
        },
        {
            title: '图斑编号',
            scopedSlots: { customRender: 'code' },
            key: 'code',
            width:260,
            align:'center'
        },
        {
            title: '实施人员',
            scopedSlots: { customRender: 'name' },
            width:140,
            align:'center'
        },
        {
            title: '前一期影像',
            scopedSlots: { customRender: 'preimage' } ,
            width:130,
            align:'center'
        },
        {
            title: '后一期影像',
            scopedSlots: { customRender: 'lstimage' } ,
            width:130,
            align:'center'
        },
        {
            title: '状态',
            scopedSlots: { customRender: 'status' } ,
            width:250,
            align:'center'
        },
        {
            title: '解译时间',
            scopedSlots: { customRender: 'time' } ,
            width:210,
            align:'center'
        },
        {
          title: '操作',
          scopedSlots: { customRender: 'operation' },
          align:'center'
        },
      ],
      task_one_table_data:[],
      task_one_pagination:{
        size:'small',
        pageSize:10,
        total:0,
        showTotal:(total, range)=>{
          return `共 ${total} 个，当前${range[0]}-${range[1]}`
        },
      },
      
      selectedRowKeys:[],
      qs_form:{
        code:'',
        name:'',
        status:'',
        taskid:''
      },
      fenpei_visible:false,
      fenpei_name:'',
      codes:[],


      org:undefined,
      role:undefined,
      work_type:"change",

      fenpei_in_visible:false,
      num_from:'',
      num_to:'',
      pic_visible:false,
      pic_imgsrc:'',
      pic_name:'',
      map_visible:false,
      Drawer_title:"",



    }
  },
  components: {
      show_png: () => import("@/components/router/show_png.vue"),
    },
  mounted() {
    this.$mitt.$on('task_manager_fenpei_taskid', (mergeid,manager_task_type,can_fenpei) => {
      this.mergeid=mergeid
      this.can_fenpei=can_fenpei
      this.selectedRowKeys=[]
      this.manager_task_type=manager_task_type
      this.manager_type_name=this.$common_apis.Get_task_type_name(manager_task_type)
      this.ClickSearch()
    })
    this.GetUser();
  },
  beforeDestroy() {
        this.$mitt.$off('task_manager_fenpei_taskid');
    },
  
  methods: {

  
    async FenPeiAdminPostIn(){
      this.fenpei_in_visible=true
      this.fenpei_name=''
      this.WaitFenPeiNameIn =new Promise((resolve)=>{this.WaitFenPeiNameIn_resolve=resolve;});
      let FenPeiNameOK=await this.WaitFenPeiNameIn
      if(FenPeiNameOK){
        this.$common_apis.axios_post("/update_admin?",{
          mergeid:this.mergeid,
          name:this.fenpei_name,
          from:this.num_from-0,
          to:this.num_to-0,
          status:this.qs_form.status,
          work_type:this.work_type,
          optype: this.manager_task_type
        },true)
        .then(res => {
          if (res) {
            this.search(this.task_one_pagination.ucurrent);
          }
        });
        return true
      }
      return false
    },
    fenpei_in_ok(){
      
    },
    name_filter(input, option) {
      return (
        option.componentOptions.children[0].text.indexOf(input) >= 0
      );
    },
    
  }
}
</script>
<style>
.showimg .demo-upload-list-cover{
    display: none;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,.6);
}
.showimg:hover .demo-upload-list-cover{
    display: block;
}
.demo-upload-list-cover i{
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    margin: 0 2px;
    margin-top: calc(50% - 10px);
}
.map_drawer .ant-drawer-body{
  height: 100%;
}
</style>